package com.sy.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.sy.dao.NewsDao;
import com.sy.dao.impl.NewsDaoImpl;
import com.sy.vo.News;

public class NewsAction extends ActionSupport {

	private static final long serialVersionUID = -5768137993751428051L;

	@SuppressWarnings("unchecked")
	private List<News> Newss;
	private News news;
	private int id;
	@SuppressWarnings("unchecked")
	public List<News> getNewss() {
		return Newss;
	}
	@SuppressWarnings("unchecked")
	public void setNewss(List<News> newss) {
		Newss = newss;
	}
	public News getNews() {
		return news;
	}
	public void setNews(News news) {
		this.news = news;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
//添加新闻
	public String add() throws Exception {

		NewsDao nadd=new NewsDaoImpl();
		news.getName();
		news.getEmail();
		news.getTitle();
		news.getContent();
		if(nadd.add(news) == 0){
			return "failure";
		}else{
		return SUCCESS;
		}
	}
	//更新新闻
	public String update() throws Exception {

		NewsDao nadd=new NewsDaoImpl();
		news.getId();
		news.getName();
		news.getEmail();
		news.getTitle();
		news.getContent();
		if(nadd.update(news) == 0){
			return "failure";
		}else{
		return SUCCESS;
		}
	}
}